import java.sql.SQLOutput;
import java.util.Scanner;

public class J2410142 {
    public static void main(String[] args) {
        int sum = 0;
        System.out.println("请输入需要计算的值：");
        Scanner in = new Scanner(System.in);
        int he = in.nextInt();
        for (int i = 0; i <= he; i++) {
            sum += fac(i);

        }
        System.out.println("sum = "+sum);

    }

    public static int fac(int n){

        int result = 1;
        for (int i = 1; i <= n; i++) {
            result *= i;
        }
        return result;
    }
}